package com.czxy.demo20;

import java.io.*;
import java.util.HashSet;
import java.util.Set;

public class Test01 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream(new File("data.txt"));
        Set<Character> set = new HashSet<>();
        byte[] buf = new byte[1024];
        int len =0;
        while((len=fis.read(buf))!=-1){
            String s = new String(buf,0,len);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i)!='\n'&&s.charAt(i)!='\r'){
                    set.add(s.charAt(i));
                }
            }
        }
        fis.close();
        String s = "";
        for (Character c : set) {
            s+=c+"";
        }
        System.out.println(s);
        OutputStream os = new FileOutputStream(new File("result.txt"));
        byte[] bb = s.getBytes();
        os.write(bb);
        os.close();
    }
}
